import json
import time

from django.http import HttpResponse
from django.shortcuts import render

def hello(request):
    return HttpResponse("Hello world ! ")


def runoob(request):
    views_list = ["菜鸟教程1", "菜鸟教程2", "菜鸟教程3"]
    return render(request, "runoob.html", {"views_list": views_list})


# def index(request):
#     views_list = ["菜鸟教程1", "菜鸟教程2", "菜鸟教程3"]
#     return render(request, "index.html", {"views_list": views_list})


def index(request):
    views_list = ["菜鸟教程1", "菜鸟教程2", "菜鸟教程3"]
    return render(request, "index.html", {"views_list": views_list})


def man(request):
    return render(request, "man.html", {})

#
# def control(request):
#     return render(request, "control.html", {})


def scene_update_view(request):
    if request.method == "POST":
        name = request.POST.get('name')
        status = 0
        result = "Error!"
        return HttpResponse(json.dumps({
            "status": status,
            "result": result
        }))


# send_time = 0

# def cal(request):
#     global send_time
#     now_time = time.perf_counter()
#     if now_time - send_time > 0.1:
#         send_time = now_time
#         num1 = request.POST.get("num1")
#         num2 = request.POST.get("num2")
#         print('cal r1et', num1, num2)
#         return HttpResponse('send')
#     return HttpResponse('ok')


def qianhou(request):
    return render(request, "qianhou.html")
